﻿@model String[]
@{
    ViewBag.Title = "角色管理";
    ViewBag.Create = "添加角色";
}


<article class="module width_full">
    @using (Html.BeginForm("AddOrEditRole", "Account"))
    {
        <header>
            <h3>@ViewBag.Create</h3>
        </header>
        <div class="module_content">
            @Html.ValidationSummary()
            <fieldset>
                <legend>@ViewBag.Create</legend>
                <ol>
                    <li>
                        <label>角色名称</label>
                        <input type="text" name="newrolename" id="newrolename"/>
                        <input type="hidden" name="oldrolename" id="oldrolename"/>
                        <input type="submit" name="rolebt" id="rolebt" value="添加" />
                    </li>
                </ol>
            </fieldset>
            <div class="clear"></div>
        </div>
    }
</article>
<article class="module width_full">
        <header>
            <h3>@ViewBag.Title</h3>
        </header>
        <div class="table_content">
            <table class="tablesorter" cellspacing="0">
                <thead>
                    <tr>
                        <th>角色名称</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var role in Model)
                    {
                        <tr>
                            <td>@role</td>
                            <td>
                                <input type="image" title="修改" src="/Content/images/icn_edit.png" onclick="changeAddtoEdit('@role')" />
                                <input type="image" title="删除" src="/Content/images/icn_trash.png" onclick="if(confirm('确认要删除角色“@role”？'))self.location='@Url.Action("DeleteRole", "Account", new { rolename = role })    '" />
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
</article>


@section scripts{
    <script>
        function changeAddtoEdit(roleName) {
            $("#newrolename").val(roleName);
            $("#oldrolename").val(roleName);
            $("#rolebt").val("修改");  
            return false;
        }
    </script>
}

